#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
const int MAXN = 6e6+7;
int prime[MAXN], p_cnt;
bool not_p[MAXN];
int phi[MAXN];
LL sumPhi[MAXN];
map<LL, LL> resMap;
void Init() {
    p_cnt = 0;
    phi[1] = 1;
    for (int i=2; i<MAXN; ++i) {
        if (!not_p[i]) {
            prime[p_cnt++] = i;
            phi[i] = i-1;
        }
        for (int j=0; j<p_cnt&&i*prime[j]<MAXN; ++j) {
            not_p[i*prime[j]] = true;
            if (i%prime[j]==0) {
                phi[i*prime[j]] = phi[i] * prime[j];
                break;
            }
            phi[i*prime[j]] = phi[i] * (prime[j] - 1);
        }
    }
    sumPhi[0] = 0;
    for (int i=1; i<MAXN; ++i) {
        sumPhi[i] = (sumPhi[i-1] + phi[i]) % MOD;
    }
}
LL solve(LL n) {
    if (n < MAXN) return sumPhi[n];
    if (resMap.count(n)) return resMap[n];
    LL ans = (__int128)n*(n+1)/2 % MOD;
    for (LL i=2, last; i<=n; i=last+1) {
        last = n/(n/i);
        ans = (ans - (__int128)(last-i+1)*solve(n/i) % MOD);
    }
    ans %= MOD;
    if (ans < 0) ans += MOD;
    resMap[n] = ans;
    return ans;
}
int main() {
#ifdef hai
    freopen("in.txt", "r", stdin);
#endif
    Init();
    LL n;
    while (~scanf("%lld", &n)) {
        printf("%lld\n", solve(n));
    }
    return 0;
}
